<?php
declare (strict_types = 1);

namespace app\middleware;
use think\facade\Session;
use app\AuthController;

class CheckUserOrJson extends AuthController
{
    /**
     * 处理请求
     *
     * @param \think\Request $request
     * @param \Closure       $next
     * @return Response
     */
    public function handle($request, \Closure $next)
    {
        #检测用户登录
        if( !(Session::has('user')) && !($this->cookie_login()) ){
            return json(['state'=>'error','info'=>'哎呀，还没登录呢，不能进行操作哦']);
        }else{
            return $next($request);
        }
    }
}
